//app.js
var util = require('utils/util.js');
App({
  onLaunch: function () {
    
  },
  getUserInfo:function(cb){
    var that = this
    if(this.globalData.userInfo){
      typeof cb == "function" && cb(this.globalData.userInfo)
    }else{
      //调用登录接口
      wx.login({
        success: function () {
          wx.getUserInfo({
            success: function (res) {
              console.log(res.userInfo)
              that.globalData.userInfo = res.userInfo
              typeof cb == "function" && cb(that.globalData.userInfo)
            }
          })
        }
      })
    }
  },
  setNumber:function(res){
    this.globalData.number = res;
  },
  setNickName:function(res){
    this.globalData.nickName = res;
  },
  getNumber:function(cb){
     if(this.globalData.number){
      typeof cb == "function" && cb(this.globalData.number);
    }else{
      util.login();
    }
  },
  getNickName:function(cb){
     if(this.globalData.nickName){
      typeof cb == "function" && cb(this.globalData.nickName);
    }else{
      util.login();
    }
  },
  globalData:{
    userInfo:null,
    number:null,
    nickName:null
  }
})